<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
    <div class="row">
    	<div class="col-lg-12">
    		<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#salary_list'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['salaries'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#import_salary'><span>
					<i class="aicon-import"></i>
					<?php echo $this->language['import_salary'];?></span></a>
				</li>
				<li>
					<a class="shortcut-button" href='#salary_formula'><span>
					<i class="aicon-salary_formula"></i>
					<?php echo $this->language['salary_formula'];?></span></a>
				</li>
			</ul>
    	</div>
    </div>
    <div class="row">
    	<div class="col-lg-7">
    		<div class="panel">
    			<div class="panel-heading">
    				<div class="panel-title"><i class="icon-list"></i> <?php echo $this->cTitle;?></div>
    			</div>
    			<div class="panel-body">
    				<table class="table table-hover table-condensed">
						<thead>
							<tr>
								<th>Tên loại lương</th>
								<th width='130px'>Số tiền</th>
							</tr>
						</thead>
						<tbody>
							<?php if(isset($this->sal_add)){
								foreach($this->sal_add as $row){ ?>
							<tr>
								<td><?php echo $row['sagr_name'];
								if($row['sagr_sali_id']==32) {
									if(count($this->projects)>0){echo "<table>";
									foreach($this->projects as $project){
										if($project['tmp_project_id'] > 0){?>
										<tr>
											<td><a href='#project_view/pid=<?php echo $project['tmp_project_id'];?>'>[<?php echo date("d/m/Y",$project['tmp_create_date']);?>] <?php echo $project['pName'];?></a></td>
											<td width='100px'><font color=red><?php echo number_format($project['tmp_amount'],0,'.',',');?> VNĐ</font></td>
										</tr>
									<?php }else{ ?>
										<tr>
											<td>[<?php echo date("d/m/Y",$project['tmp_create_date']);?>] <?php echo $project['tmp_description'];?></td>
											<td width='100px'><font color=red><?php echo number_format($project['tmp_amount'],0,'.',',');?> VNĐ</font></td>
										</tr>
									<?php }}
									echo "</table>";}
								} ?></td>
								<td><?php
		                        echo "<font color=green>";
		                        echo "+ ".number_format($row['sagr_amount'],0,'',',');
		                        echo "</font>";
		                        ?></td>
							</tr>
							<?php }} ?>
							<?php if(isset($this->sal_diff)){
								foreach($this->sal_diff as $row){ ?>
							<tr>
								<td><?php echo $row['sagr_name'];?></td>
								<td><?php
		                        echo "<font color=red>";
		                        echo "- ".number_format($row['sagr_amount'],0,'',',');
		                        echo "</font>";
		                        ?></td>
							</tr>
							<?php }} ?>
							<?php if(isset($this->sal_show)){
								foreach($this->sal_show as $row){ if(in_array($row['sagr_sali_id'],array(37,38,40,41,42,43,45))){?>
							<tr>
								<td><?php echo $row['sagr_name'];?></td>
								<td><?php
		                        echo "<font color=red>";
		                        echo "- ".number_format($row['sagr_amount'],0,'',',');
		                        echo "</font>";
		                        ?></td>
							</tr>
							<?php }}} ?>
						</tbody>
					</table>
    			</div>
    		</div>
    	</div>
    	<div class="col-lg-5">
    		<div class="panel">
    			<div class="panel-heading">
    				<div class="panel-title"><i class="icon-cog"></i> Thông tin thêm</div>
    			</div>
    			<div class="panel-body">
    				<form method="POST" class="form-horizontal" action="javascript:searchSalaryView(<?php echo $this->user['uId'];?>);">
	    				<div class="form-group">
	    					<label class="control-label col-lg-2"><?php echo $this->language['choose'];?></label>
	    					<div class="col-lg-10">
	    						<select id="sal_month" class="form-control control-inline">
									<?php for($i=1;$i<=12;$i++){
									$selected = ($i==date("n",time())) ? "selected" : "";
									echo "<option value='$i' $selected>Tháng $i</option>";
									} ?>
								</select>
								<select id="sal_year" class="form-control control-inline">
									<?php for($i=2012;$i<=2020;$i++){
									$selected = ($i==date("Y",time())) ? "selected" : "";
									echo "<option value='$i' $selected>$i</option>";
									} ?>
								</select>
	    					</div>
	    				</div>
	    				<div class="form-group">
	    					<div class="col-lg-offset-2 col-lg-10">
	    						<input type="submit" class="btn btn-primary" value="<?php echo $this->language['accept'];?>" />
	    					</div>
	    				</div>
		            </form>
		            <div class="clear"></div>
		            <?php if(isset($this->sal_show)){ ?>
		            <ul class="list-group">
		            <?php foreach($this->sal_show as $row){ ?>
		            	<li class="list-group-item">
		            		<b><?php echo $row['sagr_name'];?></b>
		            		<span class="pull-right">
		            			<?php
								if($row['sali_name']!='ngaycongchuan' && $row['sali_name']!='ngaycongthucte' && $row['sali_name']!='ngaycongtangca' && $row['sali_name']!='ngaytangcatinhcom')
									echo number_format($row['sagr_amount'],0,'.',',');
								else echo round($row['sagr_amount'],1);
								?>
		            		</span>
		            	</li>
					<?php } ?></ul><?php } ?>
    			</div>
    		</div>
    	</div>
    </div>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>